type File native;  // rx.File

type FileState {
    // rx.FileState
    name:     String,
    size:     Number,
    mode:     FileMode,
    is-dir:   Bool,
    mod-time: Time
};
type FileMode native;

export function walk-dir:
    &(Path) => Observable[(Path,FileState),Error]
    native '__SysWalkDir';

export function list-dir:
    &(Path) => Observable[(Path,FileState),Error]
    native '__SysListDir';

// TODO: consider using consumer/disposable instead of open-close
export function open-read-only:
    &(Path) => Async[File,Error]
    native '__SysOpenReadOnly';
export function open-read-write:
    &(Path) => Async[File,Error]
    native '__SysOpenReadWrite';
export function open-read-write-create:
    &(Path) => Async[File,Error]
    native '__SysOpenReadWriteCreate';
export function open-overwrite:
    &(Path) => Async[File,Error]
    native '__SysOpenOverwrite';
export function open-append:
    &(Path) => Async[File,Error]
    native '__SysOpenAppend';

export function close:
    &(File) => Async
    native '__SysFileClose';

export function get-state:
    &(File) => Async[FileState,Error]
    native '__SysFileGetState';

export function seek-start:
    &(File,Integer) => Async[Integer,Error]
    native '__SysFileSeekStart';
export function seek-delta:
    &(File,Integer) => Async[Integer,Error]
    native '__SysFileSeekDelta';
export function seek-end:
    &(File,Integer) => Async[Integer,Error]
    native '__SysFileSeekEnd';

export function read:
    &(File,Number) => Async[Bytes,Error]
    native '__SysFileRead';
export function read-all:
    &(File) => Async[Bytes,Error]
    native '__SysFileReadAll';

export function read-char:
    &(File) => Async[Char,Error]
    native '__SysFileReadChar';
export function read-line:
    &(File) => Async[String,Error]
    native '__SysFileReadLine';
export function read-lines:
    &(File) => Observable[String,Error]
    native '__SysFileReadLines';

export function write:
    &(File,Bytes) => Async[unit,Error]
    native '__SysFileWrite';
export function write-string:
    &(File,String) => Async[unit,Error]
    native '__SysFileWriteString';
export function write-line:
    &(File,String) => Async[unit,Error]
    native '__SysFileWriteLine';


